package com.leetcode.LC;

public class LC434 {
    public int countSegments(String s) {

        s=" "+s;
        int count=0;
        for (int i = 0; i < s.length()-1; i++) {
            if (s.charAt(i)==' '&&s.charAt(i+1)!=' '){
                count++;
            }
        }
        return count;

    }

    public static void main(String[] args) {
        System.out.println(new LC434().countSegments("Hello, my name is John"));
    }
}
